﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:omaneui="clr-namespace:OMANE.Common.UI;assembly=OMANE.Common.UI"
    xmlns:local="clr-namespace:OMANE.Modules.CRT"  >


    <!-- default -->
    <DataTemplate x:Key="defaulteditor">
        <TextBox Text="{Binding Path=Value}"/>
    </DataTemplate>
    <DataTemplate x:Key="defaultpresentor">
        <Border BorderThickness="2" BorderBrush="BlueViolet" Margin="10,1,0,1" CornerRadius="4" Padding="1">
            <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Path=Value}"/>
        </Border>
    </DataTemplate>

    <!-- yesno -->
    <DataTemplate x:Key="yesnopresentor">
        <Border BorderThickness="2" BorderBrush="BlueViolet" Margin="10,1,0,1" CornerRadius="4" Padding="1">
            <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" >
                  <TextBlock.Style>
                    <Style TargetType="TextBlock">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Value}" Value="False">
                                <Setter Property="Text" Value="NON" />
                                <Setter Property="Foreground" Value="Red" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Value}" Value="True">
                                <Setter Property="Text" Value="OUI" />
                                <Setter Property="Foreground" Value="Blue" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </TextBlock.Style>
            </TextBlock>
        </Border>
    </DataTemplate>
    <DataTemplate x:Key="yesnoeditor">
        <UniformGrid Columns="2" VerticalAlignment="Center">
            <RadioButton HorizontalAlignment="Center"   IsChecked="{Binding Path=Value,Mode=TwoWay}"  Content="OUI" />
            <RadioButton HorizontalAlignment="Center"  Content="NON" >
                <RadioButton.Style>
                    <Style TargetType="RadioButton">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Value}" Value="False">
                                <Setter Property="IsChecked" Value="True" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Value}" Value="True">
                                <Setter Property="IsChecked" Value="False" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </RadioButton.Style>
            </RadioButton>
        </UniformGrid>
    </DataTemplate>

    <!-- selector -->
    <DataTemplate x:Key="selectoreditor">
        <ComboBox SelectedItem="{Binding Path=Value}" ItemsSource="{Binding EditorOptions}"/>
    </DataTemplate>
    <DataTemplate x:Key="selectorpresentor">
        <Border BorderThickness="2" BorderBrush="BlueViolet" Margin="10,1,0,1" CornerRadius="4" Padding="1">
            <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Path=Value}"/>
        </Border>
    </DataTemplate>

    <!-- multiselector -->
    <DataTemplate x:Key="multiselectoreditor">
        <ListBox SelectionMode="Multiple"  >
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <UniformGrid />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="ListBoxItem">
                                <CheckBox IsChecked="{Binding Path=Selected, Mode=TwoWay}" Content="{Binding Path=Source}" />
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ListBox.ItemContainerStyle>   
            <ListBox.ItemsSource>
                <Binding>
                    <Binding.Converter>
                        <local:MultiSelectionConverter />
                    </Binding.Converter>
                </Binding>
            </ListBox.ItemsSource>
          
        </ListBox>
    </DataTemplate>
    <DataTemplate x:Key="multiselectorpresentor">
        <Border BorderThickness="2" BorderBrush="BlueViolet" Margin="10,1,0,1" CornerRadius="4" Padding="1" >
            <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap" >
                <TextBlock.Text>
                    <Binding Path="Value">
                        <Binding.Converter>
                            <local:ArrayStringConverter />
                        </Binding.Converter>
                    </Binding>
                </TextBlock.Text>
            </TextBlock>
        </Border>
    </DataTemplate>

    <!-- fileselector -->
    <DataTemplate x:Key="fileselectoreditor">
        <Button Content="{Binding}">
            <Button.ContentTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Path=Value}" TextWrapping="Wrap" />
                </DataTemplate>
            </Button.ContentTemplate>
            <Button.Command>
                <Binding ConverterParameter="file">
                    <Binding.Converter>
                        <local:FileSystemBrowserConverter />
                    </Binding.Converter>
                </Binding>
            </Button.Command>
        </Button>
    </DataTemplate>
    <DataTemplate x:Key="fileselectorpresentor">
        <Border BorderThickness="2" BorderBrush="BlueViolet" Margin="10,1,0,1" CornerRadius="4" Padding="1">
            <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" ToolTip="{Binding Path=Value}">
                <TextBlock.Text>
                    <Binding Path="Value" ConverterParameter="filename">
                        <Binding.Converter>
                            <local:FileSystemConverter />
                        </Binding.Converter>
                    </Binding>
                </TextBlock.Text>
            </TextBlock>
        </Border>
    </DataTemplate>

    <!-- folderselector -->
    <DataTemplate x:Key="folderselectoreditor">
        <Button Content="{Binding}">
            <Button.ContentTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Path=Value}" TextWrapping="Wrap" />
                </DataTemplate>
            </Button.ContentTemplate>
            <Button.Command>
                <Binding ConverterParameter="folder">
                    <Binding.Converter>
                        <local:FileSystemBrowserConverter />
                    </Binding.Converter>
                </Binding>
            </Button.Command>
        </Button>
    </DataTemplate>
    <DataTemplate x:Key="folderselectorpresentor">
        <Border BorderThickness="2" BorderBrush="BlueViolet" Margin="10,1,0,1" CornerRadius="4" Padding="1">
            <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" ToolTip="{Binding Path=Value}">
                  <TextBlock.Text>
                    <Binding Path="Value" ConverterParameter="foldername">
                        <Binding.Converter>
                            <local:FileSystemConverter />
                        </Binding.Converter>
                    </Binding>
                </TextBlock.Text>
            </TextBlock>
        </Border>
    </DataTemplate>
</ResourceDictionary>
